package com.webdiy.hr.action;

import com.sys.plat.bean.PageBean;
import com.sys.plat.util.HttpUtil;
import com.sys.plat.web.core.ActionContext;
import com.sys.plat.web.core.BaseAction;
import com.webdiy.hr.form.ZhaoPinForm;
import com.webdiy.hr.iface.ZhaoPinSerice;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: mabo
 * Date: 2010-1-6
 * Time: 21:34:36
 * To change this template use File | Settings | File Templates.
 */
public class ZhaoPinAction extends BaseAction {
    private ZhaoPinSerice getService() {
        return (ZhaoPinSerice) getService("ZhaoPinSericeImpl");
    }

    private ZhaoPinForm getForm() {
        return (ZhaoPinForm) ActionContext.getForm();
    }


    public String find() {
        PageBean pageBean = createPageBean(getForm());
        getService().findList(pageBean,getForm().getTags());
        pageBean.setToWeb();
        HttpUtil.saveSearchParemeter();
        return LIST;
    }

    public String toPage() {
        /*
        Map<String, String> map = new HashMap<String, String>();
        map.put("f(id)", "aaa");#id
        Object[][] objs = {{"findByExt", map},{"findByExt222", map}};
        */
        Map map = getForm().getFilter();
        map.put("#tags", getForm().getTags());
        Object[][] objs = {{"findByExt", map}};
        HttpUtil.fiterToWeb(objs);
        return "zhaopin_list";
    }

    //公司列表
    public String findByExt() {
        PageBean pageBean = createPageBean(getForm());
        getService().findList(pageBean,getForm().getTags());
        pageBean.setToWeb();
        HttpUtil.saveSearchParemeter();
        HttpUtil.ListToJSONByModel(pageBean.getRetList(), pageBean.getTotalrow());
        return null;
    }



    //职位列表
    public String companyListByExt() {
        if (getForm().getH() == null) {
            return null;
        }
        List list = getService().findCompanyList(getForm().getH().getId(),getForm().getTags());
        HttpUtil.ListToJSONByModel(list, list.size());
        return null;
    }

    
    public String sendListByExt() {
        PageBean pageBean = createPageBean(getForm());
        getService().sendListByExt(pageBean,getForm().getTags());
        pageBean.setToWeb();
        HttpUtil.saveSearchParemeter();
        HttpUtil.ListToJSONByModel(pageBean.getRetList(), pageBean.getTotalrow());
        return null;
    }


    //更新职位信息至待发送状态
    public String updateJobToDFSByExt() {
        getService().updateJobToDFS(getForm().getH());
        return null;
    }


    public String zhaopin() {
        //getService().callZhaoPinPage("","");
        log.warn("招聘 执行完成");
        return "login";
    }

    public String jobLoad() {
        return "login";
    }


}

